package com.headStorm.concurrent.snakeFlake;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;

import java.util.Date;

/**
 * @author zhangqq
 * @create 2021-07-22 14:57
 **/
public class SnakeFlakeUseDemo {

    public static void main(String[] args) {
        Snowflake snowflake = IdUtil.createSnowflake(2l,2l);

        IdUtil.getSnowflake(1,1);
        Long num1 = snowflake.nextId();
        Long num2 = snowflake.nextId();
        Long num3 = snowflake.nextId();
        System.out.println(num1);
        System.out.println(num2);
        System.out.println(num3);


        long generateDateTime = snowflake.getGenerateDateTime(1418104135244587009l);
        long dataCenterId = snowflake.getDataCenterId(1418104135244587009l);
        System.out.println(dataCenterId);

        System.out.println(DateUtil.format(DateUtil.parse("2021-12-28.17:06:01", "yyyy-MM-dd.HH:mm:ss"), "yyyy-MM-dd HH:mm:ss"));
    }
}
